|
|
|
|
|
|
|
When to Use Pessimistic or Optimistic Page Locking |
|
|
|
|
|
|
|
|
The advantage of using pessimistic locking is that once you begin editing a record, you can save your work because all other users are prevented from accessing that record. The disadvantage of using pessimistic locking is that if you have many people in the database, it is possible that quite a bit of the file is unavailable at any one time. |
|
|
|
|
|
|
|
|
The advantage of using optimistic locking is that it occurs only during an update and then only when required. Optimistic locks are the shortest in duration. The disadvantage of using optimistic locking is that, even though more than one user can edit a dataset record at one time, only one person can save that dataset record. This usually is the first person to complete the edit (not the person who opened the record first or the person who saves it last). This can be very frustrating for users who have filled out a lengthy data entry screen only to discover that they cannot update the data table! Except in rare cases where there is an extreme amount of network traffic, you probably will find that optimistic locking is enough. |
|
|
|
|
| |
|
|
|
|
All ODBC data sources use optimistic locking only. |
|
|
|
|
|
|
|
|
|
|
Using Cascading Updates and Deletes |
|
|
|
|
|
|
|
|
In the lesson on Day 9, ''Visual Basic and the Microsoft Jet Engine," you learned how to identify and define cascading updates and delete relationships by using the relation data-access object. At the time, a particular aspect of relation objects was not fully covered: the capability to define cascading updates and deletes in order to enforce referential integrity. By using cascading updates and deletes in your database definition, you can ensure that changes made to columns in one data table are distributed properly to all related columns in all related tables in the database. This type of referential integrity is essential when designing and using database applications accessed by multiple users. |
|
|
|
|
|
|
|
|
Microsoft Jet can enforce update and delete cascades only for native Microsoft Jet format databases. Microsoft Jet cannot enforce cascades that involve an attached table. |
|
|
|
|
| |
|
|
|
|
Cascading options should be added at database design time and can be accomplished by using the Visdata program (see Day 7, "Using the Visdata Program") or by using Visual Basic code (see Day 9). |
|
|
|
|
|
|
|